﻿using System.Web.Mvc;
using Hyt.Core.Utils;
using Hyt.Web.Security;

namespace Hyt.Web.Mvc
{
    public partial class SecurityController : Controller
    {
        public ISafeCodeProvider SafeCodeProvider { get; set; }

        #region 生成验证码图片
        /// <summary>
        /// 生成验证码图片
        /// </summary>
        /// <returns></returns>
        public ActionResult SafeCode()
        {
            var vCode = new SafeCodeImage();
            byte[] imagedate = vCode.GetImage(SafeCodeProvider.NewSafeCode(this.ControllerContext.HttpContext.Session.SessionID) );
            return File( imagedate, @"image/jpeg" );
        }
        #endregion
    }
}
